package buttons
{
   import flash.events.Event;
   import flash.events.MouseEvent;
   import flash.display.MovieClip;

   /**
    * @author   cjboy1984
    */
   public class OptionButton extends MovieClip
   {
      private static var _focusOne:OptionButton;

      /* constructor */
      public function OptionButton()
      {
         buttonMode = true;

         addEventListener(Event.ADDED_TO_STAGE, onAdd);
         addEventListener(Event.REMOVED_FROM_STAGE, onRemove);
      }

      // ------------------ LINE -------------------

      public static function get focusOne():OptionButton { return _focusOne; }
      public static function set focusOne(v:OptionButton):void
      {
         if (!v) return;

         if (_focusOne) _focusOne.gotoAndStop(1);
         v.gotoAndStop(2);
         _focusOne = v;
      }

      // ################ Protected ################

      // ################# Private #################

      private function onAdd(e:Event):void
      {
         // frame
         gotoAndStop(1);

         // listener
         addEventListener(MouseEvent.CLICK, onClick);
      }

      private function onRemove(e:Event):void
      {
         // listener
         removeEventListener(MouseEvent.CLICK, onClick);
      }

      // ------------------ LINE -------------------

      private function onClick(e:MouseEvent):void
      {
         // current
         focusOne = this;
      }

      // ------------------ LINE -------------------

   }

}